﻿/*
* ============================================================================
* GNU Lesser General Public License
* ============================================================================
*
* BYDAN - Free Java BYDAN library.
* Copyright (C) 2008 
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
* 
* BYDAN Corporation
*/
package ByDan.AulaVirtual.Business.Entities;

import java.util.ArrayList;
import ByDan.Framework.AulaVirtual.Business.Entities.GeneralEntity;
import ByDan.Framework.AulaVirtual.Business.Entities.Mensajes;
import ByDan.Framework.AulaVirtual.Utils.ParameterDbType;
import ByDan.Framework.AulaVirtual.Utils.ParameterType;
import ByDan.Framework.AulaVirtual.Utils.ParametersMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterValue;
import ByDan.Framework.AulaVirtual.Utils.ParametersType;
import java.sql.*;

public class CaracteristicaControlAjax extends GeneralEntity
{
	static  String strTableName="CaracteristicaControlAjax";
		
	public static String getStrTableName() 
	{
		return strTableName;
	}

	public static void setStrTableName(String strTableName) 
	{
		CaracteristicaControlAjax.strTableName = strTableName;
	}
	
	public static String getColumnNameId()
	{
		return "id";
	}
	
	public CaracteristicaControlAjax caracteristicacontrolajaxOriginal;
	
	public CaracteristicaControlAjax getCaracteristicaControlAjaxOriginal()
	{
		return caracteristicacontrolajaxOriginal;
	}
	
	public  void  setCaracteristicaControlAjaxOriginal(CaracteristicaControlAjax caracteristicacontrolajax)
	{
		try
		{
			caracteristicacontrolajaxOriginal=caracteristicacontrolajax;
		}
		catch(Exception ex)
		{
			;
		}
	}
	
	
	
	
	ControlAjax relationship_controlajax;
	 
	
	public ControlAjax getRelationship_ControlAjax()
	{
		return relationship_controlajax;
	}

	
	
	public  void  setRelationship_ControlAjax(ControlAjax controlajax)
	{
		try
		{
			relationship_controlajax=controlajax;
		}
		catch(Exception ex)
		{
			;
		}
	}


	
	
	ArrayList<DetalleAgrupacion> relationship_detalleagrupacions;
	ArrayList<Agrupacion> relationship_agrupacions;
	
	
	public ArrayList<DetalleAgrupacion> getRelationship_detalleagrupacions()
	{
		return relationship_detalleagrupacions;
	}

	public ArrayList<Agrupacion> getRelationship_agrupacions()
	{
		return relationship_agrupacions;
	}

	
	
	public  void  setRelationship_DetalleAgrupacion(ArrayList<DetalleAgrupacion> detalleagrupacions)
	{
		try
		{
			this.relationship_detalleagrupacions=detalleagrupacions;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_Agrupacion(ArrayList<Agrupacion> agrupacions)
	{
		try
		{
			this.relationship_agrupacions=agrupacions;
		}
		catch(Exception ex)
		{
			;
		}
	}

	
	private static Boolean blnDeleteCascade=false;
	private static String QueryInsert="insert into aulavirtualme_dbo.CaracteristicaControlAjax set IDCONTROLAJAX=?,ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,NOMBRE=?,ORDEN=?,HTMLINICIAL=?,HTMLFINAL=?,DESCRIPCION=?";
	private static String QueryUpdate="update aulavirtualme_dbo.CaracteristicaControlAjax set IDCONTROLAJAX=?,ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,NOMBRE=?,ORDEN=?,HTMLINICIAL=?,HTMLFINAL=?,DESCRIPCION=? where id=? AND versionRow=?";
	private static String QueryDelete="delete from aulavirtualme_dbo.CaracteristicaControlAjax where id=?";
	public static String QuerySelect="select aulavirtualme_dbo.CaracteristicaControlAjax.id,aulavirtualme_dbo.CaracteristicaControlAjax.IDCONTROLAJAX,aulavirtualme_dbo.CaracteristicaControlAjax.isActive,aulavirtualme_dbo.CaracteristicaControlAjax.isExpired,aulavirtualme_dbo.CaracteristicaControlAjax.versionRow,aulavirtualme_dbo.CaracteristicaControlAjax.NOMBRE,aulavirtualme_dbo.CaracteristicaControlAjax.ORDEN,aulavirtualme_dbo.CaracteristicaControlAjax.HTMLINICIAL,aulavirtualme_dbo.CaracteristicaControlAjax.HTMLFINAL,aulavirtualme_dbo.CaracteristicaControlAjax.DESCRIPCION from aulavirtualme_dbo.CaracteristicaControlAjax";
	 
	Long field_bigIdControlAjax;
	String field_strNombre;
	Integer field_intOrden;
	String field_strHtmlinicial;
	String field_strHtmlfinal;
	String field_strDescripcion;
				
	public CaracteristicaControlAjax ()
    {
		super();		
 		field_bigIdControlAjax=-1L;
 		field_strNombre="";
 		field_intOrden=-1;
 		field_strHtmlinicial=null;
 		field_strHtmlfinal=null;
 		field_strDescripcion=null;
		
		
		relationship_controlajax=new ControlAjax();
		
		
		relationship_detalleagrupacions=new ArrayList<DetalleAgrupacion>();
		relationship_agrupacions=new ArrayList<Agrupacion>();
		
		super.setQueryInsert(QueryInsert);
		super.setQueryUpdate(QueryUpdate);
		super.setQueryDelete(QueryDelete);
		super.setQuerySelect(QuerySelect);
		
    } 
	
	public static Boolean getBlnDeleteCascade() 
	{
		return blnDeleteCascade;
	}

	public static void setBlnDeleteCascade(Boolean blnDeleteCascade) 
	{
		CaracteristicaControlAjax.blnDeleteCascade = blnDeleteCascade;
	}
	
	public static String getTableName()
    {
         return "aulavirtualme_dbo.CaracteristicaControlAjax";
    }
	
    
	public static String getColumnNameidControlAjax()
	{
		return "idControlAjax";
	}
    
	public static String getColumnNameNombre()
	{
		return "Nombre";
	}
    
	public static String getColumnNameOrden()
	{
		return "Orden";
	}
    
	public static String getColumnNameHtmlInicial()
	{
		return "HtmlInicial";
	}
    
	public static String getColumnNameHtmlFinal()
	{
		return "HtmlFinal";
	}
    
	public static String getColumnNameDescripcion()
	{
		return "Descripcion";
	}
     
    
	public Long getField_bigIdControlAjax()
	{
		return field_bigIdControlAjax;
	}
    
	public String getField_strNombre()
	{
		return field_strNombre;
	}
    
	public Integer getField_intOrden()
	{
		return field_intOrden;
	}
    
	public String getField_strHtmlinicial()
	{
		return field_strHtmlinicial;
	}
    
	public String getField_strHtmlfinal()
	{
		return field_strHtmlfinal;
	}
    
	public String getField_strDescripcion()
	{
		return field_strDescripcion;
	}
	
    
	public void setField_bigIdControlAjax(Long newField_bigIdControlAjax)throws Exception
	{
		try
		{
			if(this.field_bigIdControlAjax!=newField_bigIdControlAjax)
			{
				if(newField_bigIdControlAjax==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+CaracteristicaControlAjax.getColumnNameidControlAjax());
				}

				this.field_bigIdControlAjax=newField_bigIdControlAjax;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strNombre(String newField_strNombre)throws Exception
	{
		try
		{
			if(this.field_strNombre!=newField_strNombre)
			{
				if(newField_strNombre==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+CaracteristicaControlAjax.getColumnNameNombre());
				}

				this.field_strNombre=newField_strNombre;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_intOrden(Integer newField_intOrden)throws Exception
	{
		try
		{
			if(this.field_intOrden!=newField_intOrden)
			{
				if(newField_intOrden==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+CaracteristicaControlAjax.getColumnNameOrden());
				}

				this.field_intOrden=newField_intOrden;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strHtmlinicial(String newField_strHtmlinicial)
	{
		if(this.field_strHtmlinicial!=newField_strHtmlinicial)
		{
			this.field_strHtmlinicial=newField_strHtmlinicial;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strHtmlfinal(String newField_strHtmlfinal)
	{
		if(this.field_strHtmlfinal!=newField_strHtmlfinal)
		{
			this.field_strHtmlfinal=newField_strHtmlfinal;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strDescripcion(String newField_strDescripcion)
	{
		if(this.field_strDescripcion!=newField_strDescripcion)
		{
			this.field_strDescripcion=newField_strDescripcion;
			this.setIsChanged(true);
		}
	}
		
	public  void BuildParametersMaintenance(ParameterDbType newDbType,ParametersType parametersType) throws Exception
	{
		try
		{
			ParametersMaintenance parametersMaintenance=super.getParametersMaintenance();		
			ArrayList<ParameterMaintenance> parametersTemp=new ArrayList<ParameterMaintenance>();
			ParameterMaintenance parameterMaintenance;
			ParameterValue<Long> parameterMaintenanceValueId;
			
				if(!parametersType.equals(ParametersType.DELETE))
				{		
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdControlAjax=new ParameterValue<Long>();
					parameterMaintenanceValueIdControlAjax.setValue(this.getField_bigIdControlAjax());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdControlAjax);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(2);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsactive=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsactive.setValue(this.getIsActive());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsactive);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(3);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsexpired=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsexpired.setValue(this.getIsExpired());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsexpired);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(4);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueNombre=new ParameterValue<String>();
					parameterMaintenanceValueNombre.setValue(this.getField_strNombre());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueNombre);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(5);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.INT);
					ParameterValue<Integer> parameterMaintenanceValueOrden=new ParameterValue<Integer>();
					parameterMaintenanceValueOrden.setValue(this.getField_intOrden());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueOrden);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(6);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueHtmlinicial=new ParameterValue<String>();
					parameterMaintenanceValueHtmlinicial.setValue(this.getField_strHtmlinicial());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueHtmlinicial);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(7);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueHtmlfinal=new ParameterValue<String>();
					parameterMaintenanceValueHtmlfinal.setValue(this.getField_strHtmlfinal());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueHtmlfinal);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(8);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueDescripcion=new ParameterValue<String>();
					parameterMaintenanceValueDescripcion.setValue(this.getField_strDescripcion());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueDescripcion);
					parametersTemp.add(parameterMaintenance);
					
						if(parametersType.equals(ParametersType.UPDATE))
						{					
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(9);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
							parameterMaintenanceValueId=new ParameterValue<Long>();
							parameterMaintenanceValueId.setValue(this.getId());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
							parametersTemp.add(parameterMaintenance);
							
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(10);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.TIMESTAMP);
							ParameterValue<Timestamp> parameterMaintenanceValueVersionRow=new ParameterValue<Timestamp>();
							parameterMaintenanceValueVersionRow.setValue(this.getVersionRow());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueVersionRow);		
							parametersTemp.add(parameterMaintenance);					
						}
				}
				else
				{
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					parameterMaintenanceValueId=new ParameterValue<Long>();
					parameterMaintenanceValueId.setValue(this.getId());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
					parametersTemp.add(parameterMaintenance);
				}
			
			parametersMaintenance= new ParametersMaintenance();
			parametersMaintenance.setDbType(newDbType);
			parametersMaintenance.setParametersMaintenance(parametersTemp);
			super.setParametersMaintenance(parametersMaintenance);		
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
}
